<!--工作地点-->
<template>
	<el-card>
		<el-form :inline="true" :model="state.queryForm" @keyup.enter="getDataList()">
			<el-form-item class="form-button-right">
				<el-button v-auth="'module:role:save'" type="primary" @click="addOrUpdateHandle()">新增工作地点</el-button>
				<el-button v-auth="'module:role:delete'" type="danger" @click="deleteBatchHandle()">批量删除</el-button>
			</el-form-item>

			<el-form-item>
				<KeyQuery v-model="state.queryForm.keyword" @getDataList="getDataList()" />
			</el-form-item>
		</el-form>

		<el-table v-loading="state.dataListLoading" :data="state.dataList" border style="width: 100%"
			@selection-change="selectionChangeHandle">
			<el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
			<el-table-column prop="id" label="主键" header-align="center" align="center" v-if="false"></el-table-column>

			<el-table-column prop="workplace" label="工作地点" header-align="center" align="center"></el-table-column>
			<el-table-column prop="regionName" label="国家地区" header-align="center" align="center"></el-table-column>
			<el-table-column prop="cityCode" label="所在城市" header-align="center" align="center"></el-table-column>
			<el-table-column prop="address" label="详细地址" header-align="center" align="center"></el-table-column>
			<el-table-column prop="typeName" label="类型" header-align="center" align="center"></el-table-column>

			<el-table-column prop="postal" label="邮政编码" header-align="center" align="center"></el-table-column>
			<el-table-column prop="description" label="描述" header-align="center" align="center"></el-table-column>

			<el-table-column label="操作" fixed="right" header-align="center" align="center" width="150">
				<template #default="scope">
					<el-button v-auth="'module:workplace:update'" type="primary" link
						@click="addOrUpdateHandle(scope.row.id)">修改</el-button>
					<el-button v-auth="'module:workplace:delete'" type="primary" link
						@click="deleteBatchHandle(scope.row.id)">删除</el-button>
				</template>
			</el-table-column>
		</el-table>
		<el-pagination :current-page="state.page" :page-sizes="state.pageSizes" :page-size="state.limit"
			:total="state.total" layout="total, sizes, prev, pager, next, jumper" @size-change="sizeChangeHandle"
			@current-change="currentChangeHandle">
		</el-pagination>

		<!-- 弹窗, 新增 / 修改 -->
		<add-or-update ref="addOrUpdateRef" @refreshDataList="getDataList"></add-or-update>
	</el-card>
</template>
www
<script setup lang="ts" name="ModuleWorkplaceIndex">
import { useCrud } from '@/hooks'
import { reactive, ref } from 'vue'
import { IHooksOptions } from '@/hooks/interface'

import AddOrUpdate from './plane/workplace-a-u.vue'

const state: IHooksOptions = reactive({
	dataListUrl: '/nb/workplace/page',
	deleteUrl: '/nb/workplace',
	queryForm: {}
})

const addOrUpdateRef = ref()
const addOrUpdateHandle = (id?: number) => {
	addOrUpdateRef.value.init(id)
}

const { getDataList, selectionChangeHandle, sizeChangeHandle, currentChangeHandle, deleteBatchHandle } = useCrud(state)
</script>
